package com.reran.spring.study.homework.h08.Reran_Starter.src.main.java.com.reran.starter;

import com.reran.starter.config.StarterProperties;
import com.reran.starter.model.Student;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @description:
 * @author: WangSiTeng
 * @date: 2021/12/7
 */
@Configuration
@ComponentScan("com.reran.starter.model")
@EnableConfigurationProperties(StarterProperties.class)
//@ConditionalOnProperty(prefix = "reran-starter")
public class SpringBootConfiguration {

    @Resource
    private StarterProperties properties;

    @Bean
    public Student student1001() {
        System.out.println("build student 1");
        Student student = new Student();
        student.setId(1001);
        student.setName("学员1(starter)" + this.properties.getKlassName());
        return student;
    }

    @Bean
    public Student student1002() {
        System.out.println("build student 2");
        Student student = new Student();
        student.setId(1002);
        student.setName("学员2(starter)");
        return student;
    }

}
